<template>
  <div class="footCont">
    <div
      @click="footfn(item)"
      :class="$route.path == item.url ? 'footItem_active' : 'footItem'"
      :key="index"
      v-for="(item, index) in footArr"
    >
      <div :class="'iconfont ' + item.icon"></div>
      <div class="footVal">{{ item.val }}</div>
      <div v-if="item.waitNum" class="tipNum">{{ item.waitNum }}</div>
    </div>
  </div>
</template>

<script>
import { waitOrder } from "@/http/api";
import bus from "@/assets/evnetBus.js";

export default {
  components: {},
  data() {
    return {
      footArr: [
        {
          url: "/home",
          val: "首页",
          icon: "icon-shouye-1",
          active: true,
          showNum: false
        },
        // {url:'/linkProduct',val:'服务配置',icon:'icon-lishijilu',active:false,showNum:false},
        // {url:'/subList',val:'资金',icon:'icon-zijinguanli',active:false,showNum:false},
        {
          url: "/history",
          val: "接单",
          icon: "icon-dingdan",
          active: false,
          showNum: true,
          waitNum: 0
        }
      ]
    };
  },
  props: {},
  methods: {
    footfn(item) {
      this.$router.replace({ path: item.url });
    },
    getData() {
      let data = {};
      waitOrder(data)
        .then(res => {
          this.showCont = true;
          if (res.data.code == 1) {
            this.footArr[2].waitNum = res.data.data;
          } else {
            this.showToast = true;
            this.showText = "数据获取失败";
          }
        })
        .catch(() => {
          this.showTimeOut = true;
          this.showCont = true;
        });
    }
  },
  mounted() {
    bus.$on("getWait", () => {
      this.getData();
    });
  },
  created() {
    this.getData();
  }
};
</script>

<style scoped lang="less">
.footCont {
  width: 100%;
  position: fixed;
  left: 0;
  z-index: 102;
  bottom: -1px;
  background-color: #fff;
  // border-top: 1px solid #ebebeb;
  // box-shadow: 0 -0.1rem 0.5rem #ebebeb;
  display: flex;
  justify-content: space-between;
  .footItem,
  .footItem_active {
    width: 50%;
    height: 3rem;
    display: flex;
    align-items: center;
    flex-direction: column;
    color: #999;
    justify-content: center;
    position: relative;
    .tipNum {
      position: absolute;
      top: 0.25rem;
      right: 1.5rem;
      background-color: red;
      color: white;
      padding: 0 0.35rem;
      height: 1rem;
      border-radius: 1rem;
      text-align: center;
      line-height: 1rem;
    }
    .iconfont {
      width: 1rem;
      height: 1rem;
      font-size: 1rem;
      text-align: center;
      line-height: 1rem;
    }
    .footVal {
      font-size: 0.6rem;
      margin-top: 0.1rem;
    }
  }
  .footItem_active {
    color: #4fc763;
  }
}
</style>
